<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/const/Error.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/const/Pattern.php';
?>
<SCRIPT type="text/javascript" src="/view/javascripts/form.js"></SCRIPT>
<SCRIPT type="text/javascript" src="/view/javascripts/visibility.js"></SCRIPT>
<DIV class="block">
	<H1>Типы структурных подразделений</H1>
	<TABLE>
		<TR>
			<TH>Тип структурного подразделения</TH>
			<TH>Должность руководителя</TH>
		</TR>
<?php
$posts = $response->getParameter('posts');
foreach($response->getParameter('types') as $type) {
	$id = $type->getIdentity();
	$name = $type->getName();
	$idPost = $type->getIdPost();
	$postName="";
	foreach($posts as $post) {
		if($post->getIdentity()==$idPost){
			$postName=$post->getName();
		}
	}
	$viewId = 'view-'.$id;
	$editId = 'edit-'.$id;
?>
		<TR onclick="visibility('table-row'); submitForm('edit-<?php  print $id; ?>')"
				id="<?php echo $viewId;?>">
				<form id="edit-<?php print $id; ?>" method="post" action="/departmenttype/edit.html">
<input type="hidden" value="<?php print $id ?>" name="identity">
</form>
			<TD><?php echo $name;?></TD>
				<td>
				<?php 
					echo $postName;
				?>
			</TD>
		</TR>
		
<?php
}
?>
		
	</TABLE>
</DIV>
<DIV class="block">
	<BUTTON type="button" onclick="location.href='/departmenttype/edit.html'">
		<IMG src="/view/img/button-new.png" alt="">
		<SPAN>новый</SPAN>
	</BUTTON>
</DIV>